﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using StructureMap;
using StructureMap.Configuration;
using StructureMap.Configuration.DSL;


namespace ContactManager.Models
{
    
    public class Bootstrapper : IBootstrapper

    {

        private static bool _hasStarted;

 

        public void BootstrapStructureMap()

        {

            ObjectFactory.Initialize(x =>

            {

                //x.UseDefaultStructureMapConfigFile = true;
                x.AddRegistry(new RepositoryRegistry());

                //x.AddRegistry(new SearchRegistry());

                //x.AddRegistry(new WebCoreRegistry());

                //x.AddRegistry(new RuleRegistry());

            });

        }

 

        public static void Restart()

        {

            if (_hasStarted)

            {

                ObjectFactory.ResetDefaults();

            }

            else

            {

                Bootstrap();

                _hasStarted = true;

            }

        }

 

        public static void Bootstrap()

        {

            new Bootstrapper().BootstrapStructureMap();

        }

    }


}
